﻿@page "/sdk/objects/data_source/l/{PageName?}"

@model WebVella.Erp.Plugins.SDK.Pages.ErpDataSource.ListModel

@{
	Layout = "~/Pages/_AppMaster.cshtml";
	ViewData["Title"] = "Datasources";
	var titleAction = "<a href=\"javascript:void(0)\" class=\"clear-filter-all\">clear all</a>";
}
<wv-page-header color="#dc3545" area-label="Data Sources" title="All data sources"
				icon-class="fa fa-cloud-download-alt" description="@Model.PageDescription">
	<wv-page-header-actions>
		@foreach (var action in Model.HeaderActions)
		{
			@Html.Raw(action)
		}
	</wv-page-header-actions>
</wv-page-header>

<wv-grid columns="@Model.Columns" bordered="true" hover="true" records-count="@Model.Records.Count" page="@Model.Page" page-size="@Model.PageSize" total-count="@Model.TotalCount">
	@foreach (var record in Model.Records)
	{
		<wv-grid-row>
			<wv-grid-column>
				@Html.Raw(record["action"])
			</wv-grid-column>
			<wv-grid-column>
				@Html.Raw(record["icon"])
			</wv-grid-column>
			<wv-grid-column>
				@Html.Raw(record["name"])
			</wv-grid-column>
			<wv-grid-column>
				@Html.Raw(record["type_description"])
			</wv-grid-column>
			<wv-grid-column>
				@if ((int)record["type"] == 0)
				{
					<div><span class="go-gray">Entity: </span>@record["target"]</div>
				}
				else
				{
					<div><span class="go-gray">Class: </span>@record["target"]</div>
				}
			</wv-grid-column>
			<wv-grid-column>
				<code>@record["model"]</code>
			</wv-grid-column>
			<wv-grid-column>
				@Html.Raw(record["param_count"])
			</wv-grid-column>
		</wv-grid-row>
	}
</wv-grid>

<wv-drawer width="550px" title="Search Data Sources" title-action-html="@titleAction">
	<form method="get" name="SearchDataSources">
		<wv-filter-text name="name" label="Name" query-type="CONTAINS" query-options="@Model.FilterTypes"></wv-filter-text>
		<wv-filter-text name="target" label="Target" query-type="CONTAINS" query-options="@Model.FilterTypes"></wv-filter-text>
		<wv-filter-text name="model" label="Returned Model" query-type="CONTAINS" query-options="@Model.FilterTypes"></wv-filter-text>
		<wv-filter-select name="type" label="Type" query-type="CONTAINS" value-options="@Model.TypeOptions" query-options="@(new List<FilterType> { FilterType.EQ })"></wv-filter-select>
		<hr class="divider" />
		<button type="submit" class="btn btn-sm btn-white">Search Data Sources</button>
	</form>
</wv-drawer>
